Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
capacity_exhausted.Fix
idleSeconds(its warm period). When a workspace on that profile has had no request activity for that long, PocketCoder drains it: the usual drain stops the compute and frees its capacity. Its sessions becomesuspendedwith the reasonworkspace_idle, and they place again when they get new work.idleSecondskeep today's behavior.drainIdleCapacity(packages/db/src/modules/budgets/capacity-idle.ts) runs at the start of the existing session recovery tick. Under the capacity lock it selects launched, non-draining capacity past its warm period, skips workspaces that are not ready or still run an execution, and skips sessions with queued work.idle_secondsis a new nullable column onmanaged_profiles(generated migration).packages/server/src/sessions/shared-placement-flow.test.tsfailed in CI before the fix (run 47228037007,units (4)), on the temporary branchtest/pc-220-red(now deleted).bun run checkandbun run typecheckpass locally.units (4)andstores. The idle filter only accepted capacity in statelaunch_claimed, and the test fixture's capacity staysreserved. The filter now matches the idle victim: a ready workspace with no running execution. All 8 tests inshared-placement-flow.test.tspass on the GCE test host.bun run example:e2e:e2b-idle-reclaimpassed on the two-worker E2B cluster from PC-200 (revision 93116d8, profileidleSeconds: 60):suspended/workspace_idle.drainingAtpath, so stopping and freeing the slot stays in one place. Busy workspaces are skipped rather than interrupted.Background
idleVictim) only drains when someone else is waiting. Reusing itsdrainingAtmarker means the recovery tick and the launch flow handle idle drains with no new states.lastUsedAtis already bumped on each request write, so it is the activity clock.Downsides
managed_profiles.idle_seconds).idleSecondswith that in mind.Notes
feature/pc-205-tenant-access)..changeset/session-idle-reclaim.md(CLI and SDK, minor).docs/managed-consumers.mdprofile example anddocs/managed-runtime.mdwarm-period paragraph.examples/e2e/e2b-idle-reclaim.ts. It prints a timestamped mark at each step. Host samples were taken every 10 s on both workers. Each value below is the mean over the 30 s quiet window after a mark. The VM ran on worker A.Guest memory lives in the reserved hugepages, so the Firecracker RSS stays small. The host's ordinary memory use stayed at about 5.2 GiB, including the 4 GiB hugepage reservation.